import { login, register } from '@/api/user';

const state = {
	user: null,
	isLogin: false
}

const mutations = {
	setUser(state, data) {
		state.user = data;
	}
}

const actions = {
	login({ commit }) {
		console.log('login');
		
		login('phone', 'password').then((data) => {
			commit('setUser', data);
		})
	},
	register({ commit }){
		register('phone', 'password', 'email').then((data) => {
			commit('setUser', data);
		})
	}
}

export default {
	state,
	mutations,
	actions
}